class AddUserIdsToModels < ActiveRecord::Migration
  def self.up
    #actually create join tables, not add ids
    create_table :stores_users, :id => false do |t|
      t.column :user_id, :integer
      t.column :store_id, :integer
    end
    create_table :posts_users, :id => false do |t|
      t.column :user_id, :integer
      t.column :post_id, :integer
    end
    create_table :products_users, :id => false do |t|
      t.column :user_id, :integer
      t.column :product_id, :integer
    end
    user = User.find_by_login("philleif")
    for p in Product.find(:all)
      user.products << p
    end
    for p in Post.find(:all)
      user.posts << p
    end
    for s in Store.find(:all)
      user.stores << s
    end
  end

  def self.down
    drop_table :stores_users
    drop_table :posts_users
    drop_table :products_users
  end
end
